#include <iostream>
using namespace std;

//弧结点
struct ArcNode {
    int adjvex;
    ArcNode *nextarc;
};

//顶点结点
struct VexNode {
    char data;
    ArcNode *firstarc;
};

//邻接表
#define M 100
struct ALGraph {
    VexNode vexs[M];
    int vexnum, arcnum;
};

int main()
{
    //创建图的邻接表
    ALGraph G = {
        { //初始化vexs[]
            {'A', new ArcNode{1, new ArcNode{2, nullptr}}},
            {'B', new ArcNode{4, nullptr}},
            {'C', new ArcNode{1, new ArcNode{3, nullptr}}},
            {'D', new ArcNode{1, nullptr}},
            {'E', new ArcNode{0, new ArcNode{3, nullptr}}}
        },
        5, 8 //初始化vexnum,
    };
    
    //打印邻接表
    for(int i = 0; i < G.vexnum; i++) {
        cout << G.vexs[i].data << ": ";
        for(auto p = G.vexs[i].firstarc; p; p = p -> nextarc)
            cout << G.vexs[p->adjvex].data << " ";
        cout << endl;
    }
    return 0;
}